|
Bilinear filtering is a texture filtering method used to smooth textures when displayed larger or smaller than they actually are. Most of the time, when drawing a textured shape on the screen, the texture is not displayed exactly as it is stored, without any distortion. Because of this, most pixels will end up needing to use a point on the texture that is "between" texels, assuming the texels are points (as opposed to, say, squares) in the middle (or on the upper left corner, or anywhere else; it does not matter, as long as it is consistent) of their respective "cells". Bilinear filtering uses these points to perform bilinear interpolation between the four texels nearest to the point that the pixel represents (in the middle or upper left of the pixel, usually). ==The formula== In a mathematical context, bilinear interpolation is the problem of finding a function f(x,y) of the form : satisfying : The usual, and usually computationally least expensive way to compute is through linear interpolation used twice, for example to compute two functions and satisfying : and then to combine these functions (which are linear in ) into one function satisfying : In computer graphics, bilinear filtering is usually performed on a texture during texture mapping, or on a bitmap during resizing. In both cases, the source data (bitmap or texture) can be seen as a two-dimensional array of values , or several (usually three) of these in the case of full-color data. The data points used in bilinear filtering are the 2x2 points surrounding the location for which the color is to be interpolated. Additionally, one does not have to compute the actual coefficients of the function ; computing the ''value'' is sufficient. The largest integer not larger than x shall be called , and the fractional part of shall be . Then, , and . We have , , , . The data points used for interpolation are taken from the texture / bitmap and assigned to , , , and . , are the two data points for subtracting the former from the latter yields : Because is linear, its derivative is constant and equal to : Because , : and similarly, : Because , we have computed the endpoints and needed for the second interpolation step. The second step is to compute , which can be accomplished by the very formula we used for computing the intermediate values: : In the case of scaling, y remains constant within the same line of the rescaled image, and storing the intermediate results and reusing them for calculation of the next pixel can lead to significant savings. Similar savings can be achieved with all "bi" kinds of filtering, i.e. those which can be expressed as two passes of one-dimensional filtering. In the case of texture mapping, a constant x or y is rarely if ever encountered, and because today's (2000+) graphics hardware is highly parallelized, there would be no time savings anyway. Another way of writing the bilinear interpolation formula is : 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Bilinear filtering」の詳細全文を読む スポンサード リンク
|